#ifndef _WX_POPUPWIN_H_BASE_
#define _WX_POPUPWIN_H_BASE_

#include "wx/defs.h"

#if wxUSE_POPUPWIN

#include "wx/window.h"

// ----------------------------------------------------------------------------
// wxPopupWindow: a special kind of top level window used for popup menus,
// combobox popups and such.
// ----------------------------------------------------------------------------

class wxPopupWindowBase : public wxWindow {
  public:
    wxPopupWindowBase() { }
    virtual ~wxPopupWindowBase();

    // create the popup window
    //
    // style may only contain border flags
    bool Create( wxWindow *parent, int style = wxBORDER_NONE );

    // move the popup window to the right position, i.e. such that it is
    // entirely visible
    //
    // the popup is positioned at ptOrigin + size if it opens below and to the
    // right (default), at ptOrigin - sizePopup if it opens above and to the
    // left &c
    //
    // the point must be given in screen coordinates!
    virtual void Position( const wxPoint& ptOrigin,
                           const wxSize& size );

    virtual bool IsTopLevel() const { return true; }

    DECLARE_NO_COPY_CLASS( wxPopupWindowBase )
};


// include the real class declaration
#if defined(__WXGTK20__)
#include "wx/gtk/popupwin.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/popupwin.h"
#elif defined(__WXX11__)
#include "wx/x11/popupwin.h"
#endif

class wxPopupWindowHandler;
class wxPopupFocusHandler;

class wxPopupTransientWindow : public wxPopupWindow {
  public:
    wxPopupTransientWindow() { Init(); }
    wxPopupTransientWindow( wxWindow *parent, int style = wxBORDER_NONE );
    virtual ~wxPopupTransientWindow();
    virtual void Popup( wxWindow *focus = NULL );
    virtual void Dismiss();
    virtual bool CanDismiss() { return true; }
    virtual bool ProcessLeftDown( wxMouseEvent& event );
    virtual bool Show( bool show = true );
  protected:
    void Init();
    virtual void OnDismiss();
    void DismissAndNotify();
    void PopHandlers();
    void OnDestroy( wxWindowDestroyEvent& event );
    wxWindow *m_child;
    wxWindow *m_focus;
    friend class wxPopupWindowHandler;
    friend class wxPopupFocusHandler;
    wxPopupWindowHandler *m_handlerPopup;
    wxPopupFocusHandler  *m_handlerFocus;
    DECLARE_EVENT_TABLE()
    DECLARE_DYNAMIC_CLASS( wxPopupTransientWindow )
    DECLARE_NO_COPY_CLASS( wxPopupTransientWindow )
};

#if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)

#error mmmmm
class wxComboBox;
class wxComboCtrl;

class wxPopupComboWindow : public wxPopupTransientWindow {
  public:
    wxPopupComboWindow() { m_combo = NULL; }
    wxPopupComboWindow( wxComboCtrl *parent );

    bool Create( wxComboCtrl *parent );

    // position the window correctly relatively to the combo
    void PositionNearCombo();

  protected:
    // notify the combo here
    virtual void OnDismiss();

    // forward the key presses to the combobox
    void OnKeyDown( wxKeyEvent& event );

    // the parent combobox
    wxComboCtrl *m_combo;

    DECLARE_EVENT_TABLE()
    DECLARE_DYNAMIC_CLASS( wxPopupComboWindow )
};

#endif // wxUSE_COMBOBOX && defined(__WXUNIVERSAL__)

#endif // wxUSE_POPUPWIN

#endif // _WX_POPUPWIN_H_BASE_
